#!/bin/sh
npm config set registry https://registry.npmmirror.com
node -v

git pull

cp -f package.json new.json

if [ -f "old.json" ]; then
 file1=new.json
 file2=old.json
 diff $file1 $file2 > /dev/null
 # shellcheck disable=SC3014
 # shellcheck disable=SC2181
 if [ $? == 0 ]; then
    echo "Both file are same"
 else
    echo "Both file are different"
    npm install
 fi
else
 npm install
 echo "init: install..."
fi

cp -f package.json old.json

npm run stage
pm2 start
